package com.tdy.application;

import com.tdy.core.WebApplication;
import com.tdy.resource.HelloWorldResource;
import com.tdy.servlet.JsonMapperResovler;
import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.jaxrs.listing.SwaggerSerializers;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;

/**
 * Created by tangdaoyuan on 15/11/26.
 */
public class JerseyApplication extends WebApplication {
    public JerseyApplication() {
        //register resource class
        register(ApiListingResource.class);
        register(SwaggerSerializers.class);
        register(JacksonFeature.class);
        register(MultiPartFeature.class);
        register(HelloWorldResource.class);
        register(JsonMapperResovler.class);
        initSwagger();
    }
    public void initSwagger()
    {
        BeanConfig beanConfig=new BeanConfig();
        beanConfig.setVersion("1.0.0");
        beanConfig.setSchemes(new String[]{"http"});
        beanConfig.setHost("localhost:8080");
        beanConfig.setBasePath("/");
        beanConfig.setResourcePackage("com.tdy.resource");
        beanConfig.setScan(true);
    }

}
